/**
  ******************************************************************************
  * @file    usbd_composite.h
  * @author  Ficusdx
  * @brief   header file for the usbd_composite.c file.
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
  * All rights reserved.</center></h2>
  *
  * This software component is licensed by ST under Ultimate Liberty license
  * SLA0044, the "License"; You may not use this file except in compliance with
  * the License. You may obtain a copy of the License at:
  *                      www.st.com/SLA0044
  *
  ******************************************************************************
  */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USB_COMMON_H
#define __USB_COMMON_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "usbd_ioreq.h"
#include "usbd_cdc.h"
#include "usbd_msc.h"

#define USBD_CDC_CONFIG_DESC_SIZ        75
#define USBD_COMP_CONFIG_DESC_SIZ       98

#define USBD_INTERFACE_NUM_CDC_COMMAND  0
#define USBD_INTERFACE_NUM_CDC_DATA     1
#define USBD_INTERFACE_NUM_MSC          2

#define USBD_HANDLE_INDEX_CDC           0
#define USBD_HANDLE_INDEX_MSC           1

#define USBD_GETHANDLE_CDC(pdev)        (((USBD_COM_DataTypeDef*)pdev->pClassData)->hcdc)
#define USBD_GETITF_CDC(pdev)           (((USBD_COM_ITFTypeDef*)pdev->pUserData)->cdcItf)

#define USBD_GETHANDLE_MSC(pdev)        (((USBD_COM_DataTypeDef*)pdev->pClassData)->hmsc)
#define USBD_GETITF_MSC(pdev)           (((USBD_COM_ITFTypeDef*)pdev->pUserData)->storageItf)


/**
 * 通用用户接口
 */
typedef struct
{
    USBD_CDC_ItfTypeDef *cdcItf;
    USBD_StorageTypeDef *storageItf;
} USBD_COM_ITFTypeDef;

/**
 * 通用类数据
 */
typedef struct
{
    USBD_CDC_HandleTypeDef *hcdc;
    USBD_MSC_BOT_HandleTypeDef *hmsc;
} USBD_COM_DataTypeDef;


extern const USBD_COM_ITFTypeDef USBD_COMP_Interface;


uint8_t USBD_COM_RegisterCommonInterface(USBD_HandleTypeDef *pdev);
uint8_t USBD_COM_PreInit(USBD_HandleTypeDef *pdev);
uint8_t USBD_COM_NextDeInit(USBD_HandleTypeDef *pdev);

#ifdef __cplusplus
}
#endif

#endif  /* __USB_COMMON_H */


/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
